package LanQiao._13JavaB;

import java.util.Scanner;

public class _6最大子矩阵 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = 20;
        int[][] arr = new int[][]{
            {6,9,8,5,9,2,4,1,8,3,9,3,8,7,8,6,8,9,4,1},
            {1,7,6,1,5,8,7,6,9,6,3,1,3,1,7,5,9,2,8,4},
            {3,7,3,4,7,3,4,8,3,2,6,6,2,7,4,8,3,4,8,5},
            {5,3,6,7,1,2,5,6,5,5,6,1,6,7,8,6,4,7,4,3},
            {1,6,1,2,1,6,8,6,9,2,7,4,3,2,3,2,9,4,7,9},
            {1,3,5,4,7,4,1,3,3,4,9,9,6,2,7,7,3,4,4,7},
            {2,7,9,7,9,9,4,5,9,2,9,8,4,8,8,2,4,6,8,7},
            {5,3,7,7,6,9,8,3,3,4,6,8,3,8,7,9,1,3,7,9},
            {5,6,4,9,3,4,2,1,3,6,5,3,6,5,7,1,7,7,4,5},
            {2,1,9,2,4,3,7,9,2,9,3,8,7,2,6,1,1,3,8,2},
            {9,3,9,1,9,3,5,3,2,1,6,2,4,3,5,6,1,2,7,7},
            {5,4,2,9,6,1,4,4,7,6,3,9,6,9,2,5,7,7,8,8},
            {9,6,2,3,3,9,7,2,5,1,3,7,9,4,7,3,2,9,3,3},
            {8,1,4,4,3,4,9,4,5,3,3,1,2,9,9,3,9,9,7,5},
            {6,1,1,7,1,8,8,2,9,8,8,8,7,7,5,9,3,4,9,9},
            {6,1,2,1,6,8,6,8,8,9,5,7,2,1,3,4,8,5,2,2},
            {5,5,4,8,5,3,4,5,9,5,9,2,9,4,7,2,6,8,9,6},
            {3,2,1,2,4,9,6,3,3,1,8,2,4,2,5,5,4,9,2,2},
            {1,3,5,9,3,6,4,7,1,9,1,9,3,4,2,7,2,6,9,6},
            {5,6,4,3,6,8,9,5,9,4,4,9,1,9,8,9,9,2,4,6}
        };
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (i > 15){
                break;
            }
            for (int j = 0; j < n; j++) {
                if (j > 15) break;
                int sum = 0;
                for (int i1 = 0; i1 < 5; i1++) {
                    for (int j2 = 0; j2 < 5; j2++) {
                        int num = arr[i + i1][j + j2];
                        sum += num;
                    }
                }
                max = Math.max(max, sum);
            }
        }
        System.out.println(max);
        scan.close();
    }
}
